// @ts-nocheck

import type { App } from 'vue'

// 需要全局引入一些组件，如ElScrollbar，不然一些下拉项样式有问题
import { ElLoading,  ElMessage } from 'element-plus'

const plugins = [ElLoading]


export const setupElementPlus = (app: App<Element>) => {
    plugins.forEach((plugin) => {
        app.use(plugin)
    })

    const ElMessageCfg = { duration: 2000, customClass: 'globalElMessageStyle' }
    app.config.globalProperties.$ElMessage = (msg: String) => {
        return ElMessage({ message: msg, ...ElMessageCfg })
    }
    app.config.globalProperties.$ElMessage.success = (msg: String) => {
        return ElMessage.success({ message: msg, ...ElMessageCfg })
    }
    app.config.globalProperties.$ElMessage.warning = (msg: String) => {
        return ElMessage.warning({ message: msg, ...ElMessageCfg })
    }
    app.config.globalProperties.$ElMessage.info = (msg: String) => {
        return ElMessage.info({ message: msg, ...ElMessageCfg })
    }
    app.config.globalProperties.$ElMessage.error = (msg: String) => {
        return ElMessage.error({ message: msg, ...ElMessageCfg })
    }
}
